package top.wuyang.trywork.controller;


import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import top.wuyang.trywork.base.PageBean;
import top.wuyang.trywork.base.R;
import top.wuyang.trywork.entity.TbBillboard;
import top.wuyang.trywork.service.TbBillboardService;
import top.wuyang.trywork.vo.PageVO;

@RestController
@RequestMapping("/billboard")
@RequiredArgsConstructor
public class TbBillboardController {
    private final TbBillboardService tbBillboardService;

    // 添加
    @PostMapping("")
    public R<String> insert(@RequestBody TbBillboard tbBillboard){return tbBillboardService.insert(tbBillboard);}

    // 查询
    @GetMapping("/{pn}/{ps}")
    public R<PageVO<TbBillboard>> queryPage(@PathVariable("pn") Long pageNumber, @PathVariable("ps") Long pageSize,TbBillboard tbBillboard){
        return tbBillboardService.queryPage(PageBean.instance(pageNumber,pageSize),tbBillboard);
    }

    // 主键查询
    @GetMapping("/{id}")
    public R<TbBillboard> queryById(@PathVariable("id") Integer id) {
        return tbBillboardService.queryById(id);
    }

    @PutMapping("")
    public R<String> update(@RequestBody TbBillboard tbBillboard) {
        return tbBillboardService.update(tbBillboard);
    }

    @DeleteMapping("/{id}")
    public R<String> delete(@PathVariable("id") Integer id) {
        return tbBillboardService.delete(id);
    }




}
